package cn.dnui_lxx432.dnuifood_16110100432.controller;


import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.widget.Button;
import android.widget.EditText;



import cn.dnui_lxx432.dnuifood_16110100432.R;


public class SearchFragment extends BaseFragment {
    private View view;
    private Button btn_ok;

    private EditText et_search;
    public SearchFragment() {

    }
    @Override
    public void onViewCreated(@NonNull View views, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(views, savedInstanceState);
        this.view=views;
        initViews();
        initEvent1();
    }

    public void initEvent1(){

        btn_ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                showDetailInfo(et_search.getText().toString().trim());
            }
        });

    }

    public void initViews(){
        btn_ok=view.findViewById(R.id.btn_ok);

        et_search=view.findViewById(R.id.et_search);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_search, container, false);
    }



    void showDetailInfo(String name){

        if (!name.equals(" ")) {
            Intent intent = new Intent(getActivity(), SearchResultActivity.class);
            intent.putExtra("search", name);
            startActivity(intent);
        }
    }

}
